Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | export const dynamic = 'force-dynamic' import {notFound} from 'next/navigation' import {prisma} from '@/lib/db' import {displayName, getSong, isImportNote} from '@/lib/songs' import ChartScreen from '@/components/ChartScreen' import {pageSession} from '@/lib/guard' import {followToBand} from '@/lib/band' import {myCues} from '@/lib/cues-server' export async function generateMetadata({params}: {params: {id: string}}) { const {band} = await pageSession() const song = await prisma.song.findFirst({ where: {id: params.id, bandId: band.id}, select: {title: true}, }) return {title: song?.title ?? 'Song'} } export default async function SongPage({params}: {params: {id: string}}) { const {user, band} = await pageSession() const song = await getSong(params.id, band.id) if (!song) { await followToBand('song', params.id, user.id, `/songs/${params.id}`) notFound() } const [versions, cues] = await Promise.all([ prisma.chartVersion.count({where: {songId: song.id}}), myCues(user.id, [song.id]), ]) return ( <ChartScreen song={{ id: song.id, title: song.title, writer: song.writer, leadSinger: song.leadSinger, guitars: song.guitars, seconds: song.seconds, keys: song.keys, percussion: song.percussion, youtubeUrl: song.youtubeUrl, lyricsUrl: song.lyricsUrl, notes: song.notes, ready: song.status === 'READY', }} source={song.latest?.source ?? ''} version={song.latest?.number ?? 0} versions={versions} editedBy={song.latest ? displayName(song.latest.author) : null} editedAt={song.latest?.createdAt.toISOString() ?? null} imported={isImportNote(song.latest?.note)} cues={cues.get(song.id) ?? []} /> ) } |